﻿using System.Threading;
using System.Windows.Forms;
using BuildStatusIndicator.BuildScreen;
using BuildStatusIndicator.Controller;
using BuildStatusIndicator.Controller.EventBroker;
using BuildStatusIndicator.Controller.TfsConnectionStatergy;
using BuildStatusIndicator.ControllerTests.Stubs;
using BuildStatusIndicator.DelCom;
using BuildStatusIndicator.DelCom.Hardware;
using BuildStatusIndicator.DelCom.Stubs;
using BuildStatusIndicator.Properties;
using BuildStatusIndicator.X10;
using BuildStatusIndicator.X10.Hardware;
using BuildStatusIndicator.X10.Stubs;
using Microsoft.Practices.Unity;

namespace BuildStatusIndicator
{
    public class Configuration
    {
        public static void ContainerConfiguration(IUnityContainer container)
        {
            IConnectinonStratergy statergy = ConnectionStrategyFactory
                .Create(Settings.Default.ServerUrl,
                        Settings.Default.TeamProject,
                        Settings.Default.PollingIntervall,
                        Settings.Default.Username,
                        Settings.Default.Password);


            container
                .RegisterInstance(statergy)
                .RegisterType<IBuildStatusEventPublisher, BuildStatusEventPublisher>(
                new ContainerControlledLifetimeManager())
                .RegisterType<SynchronizationContext, WindowsFormsSynchronizationContext>()
                .RegisterType<IBuildScreenView, BuildScreenForm>(
                new ContainerControlledLifetimeManager())
                .RegisterType<BuildScreenPresenter>()
                
                //ProductionConfig
                .RegisterType<IController, TfsController>(new ContainerControlledLifetimeManager())
                .RegisterType<IDelComVisualSignalIndicator, DelComVisualSignalIndicatorHandle>()
                //.RegisterType<IX10SignalIndicator, X10SignalIndicator>()

                //TestConfig
                //.RegisterType<IController, ControllerStub>(new ContainerControlledLifetimeManager())
                //.RegisterType<IDelComVisualSignalIndicator, DelComVisualSignalIndicatorHandleStub>()
                //.RegisterType<IX10SignalIndicator, X10SignalIndicatorStub>()
                ;
        }
    }
}